package com.sky.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.mapper.OrderListMapper;
import com.sky.result.PageResult;
import com.sky.service.OrderListService;
import com.sky.vo.OrderStatisticsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderListServiceImpl implements OrderListService {
    @Autowired
    private OrderListMapper orderListServiceMapper;
    @Override
    public List<OrderStatisticsVO> list() {
        return orderListServiceMapper.list();
    }

    @Override
    public PageResult pageQuery(OrdersPageQueryDTO ordersPageQueryDTO) {

        PageHelper.startPage(ordersPageQueryDTO.getPage(), ordersPageQueryDTO.getPageSize());
        Page<Orders> page = orderListServiceMapper.pageQuery(ordersPageQueryDTO);//查出分页数据
        List<Orders> result = page.getResult();
        long total = page.getTotal();
        return new PageResult(total, result);
    }

    @Override
    public List<OrderDetail> getOrersById(Integer id) {
        return orderListServiceMapper.getOrdersDetail(id);
    }
}
